<?php
/**
 * 控制器基礎類 初始化組件
 * @author     Shuxun Team <kaiping.jiang@scshux.com>
 */
namespace  Scshux\Mvc;
use Phalcon\Mvc\Url;
use Phalcon\Mvc\Model\Validator\StringLength;
use Phalcon\Di\FactoryDefault;
class  UrlResolver extends  Url
{

     /**
      * 处理url
      * @see \Phalcon\Mvc\Url::get()
      */
     public function get($uri=null, $args=null, $local=null)
     {

     	 $config = FactoryDefault::getDefault()->get('config');
     	 if(!isset($config->adminPath)){
     	 	$config->adminPath = 'admin';
     	 }

     	 if(isset($config->currentModule) && $config->currentModule == 'backend'){
     	 	if(substr($uri, 0,1) != '/'){
     	 		$uri =  $config->adminPath.'/'.$uri;
     	 	}
     	 }
		 $uri = ltrim($uri,'/');
         /**
          * 修復url,$uri必須帶模組名稱,如果當前是該模組則去除模組名稱
          */
         return  parent::get($uri,$args,$local);
     }

}